from django.db import models

class NewsCategory(models.Model):
	name = models.CharField(max_length = 100)

class WriteNews(models.Model):
	pub_time = models.DateTimeField(auto_now_add = True)
	title = models.CharField(max_length = 100)
	desc = models.CharField(max_length = 100)
	category = models.ForeignKey('NewsCategory',on_delete=models.SET_NULL,null=True)
	thumbnail = models.FileField()
	content = models.TextField()
	author = models.ForeignKey('xfzauth.User',on_delete=models.SET_NULL,null=True)

	class Meta:
		ordering = ['-pub_time']

class Comment(models.Model):
	pub_time = models.DateTimeField(auto_now_add = True)
	comment = models.CharField(max_length = 200)
	author = models.ForeignKey('xfzauth.User',on_delete=models.CASCADE)
	news = models.ForeignKey('WriteNews',on_delete=models.CASCADE)

	class Meta:
		ordering = ['-pub_time']